<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>毕业生信息管理系统</title>
		<meta name="description" content="这是一个 index 页面">
		<meta name="keywords" content="index">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="icon" type="image/png"
			href="<%=Const.ROOT%>assets/i/favicon.png">
		<link rel="apple-touch-icon-precomposed"
			href="<%=Const.ROOT%>assets/i/app-icon72x72@2x.png">
		<meta name="apple-mobile-web-app-title" content="Amaze UI" />
		<link rel="stylesheet"
			href="<%=Const.ROOT%>assets/css/amazeui.min.css" />
		<link rel="stylesheet" href="<%=Const.ROOT%>assets/css/admin.css">
		<link rel="stylesheet" href="<%=Const.ROOT%>assets/css/app.css">
		<script src="<%=Const.ROOT%>My97DatePicker/WdatePicker.js"></script>
	</head>

	<body data-type="generalComponents">

		<%@include file="top.jsp"%>

		<div class="tpl-page-container tpl-page-header-fixed">
			<!--左边start-->
			<%@include file="sidebar.jsp"%>
			<!--左边end-->
			<div class="tpl-content-wrapper">
				<!--右边内容start-->
				<ol class="am-breadcrumb">
					<li>
						<a href="<%=Const.ROOT%>manage/index.jsp" class="am-icon-home">首页</a>
					</li>
					<li class="am-active">
						奖惩记录列表
					</li>
				</ol>
				<div class="tpl-portlet-components">
					<div class="tpl-block">
					<form action="repe_list.action" method="post" id="sform"">
      				<input type="hidden" name="pageBean.pageNo" value="1" id="pageNo"/>
						<div class="am-g">
								<div class="am-u-sm-12 am-u-md-3">
								<div class="am-btn-toolbar">
									<div class="am-btn-group am-btn-group-xs">
									<s:if test="#session.role==2">	
										<button type="button"
											class="am-btn am-btn-default am-btn-success" onclick="add()">
											<span class="am-icon-plus"></span> 新增
										</button>
										</s:if>
									</div>
								</div>
								</div>
								<div class="am-u-sm-12 am-u-md-3">
									<div class="am-input-group am-input-group-sm">
										<input type="text" name="name" class="am-form-field"
											value="<s:property value="name"/>" placeholder="学生姓名">
										<span class="am-input-group-btn">
											<button
												class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search"
												type="submit"></button> </span>
									</div>
								</div>
						</div>
						<div class="am-g">
							<div class="am-u-sm-12">
									<table
										class="am-table am-table-striped am-table-hover table-main">
										<thead>
											<tr>
												<th class="table-id">编号</th>
												<th class="table-title">学生名称</th>
												<th class="table-title">内容</th>
												<th class="table-title">时间</th>
												
												<s:if test="#session.role==2">
												<th class="table-set">操作</th>
												</s:if>
											</tr>
										</thead>
										<tbody>
										<s:iterator value="list" status="st">
											<tr>
												<!--行start-->
												<td><s:property value="#st.count"/></td>
											
												<td><s:property value="student.name"/></td>
												<td><s:property value="content"/></td>
												<td><s:property value="rtime"/></td>
												
												<td>
													<div class="am-btn-toolbar">
														<div class="am-btn-group am-btn-group-xs">
															<s:if test="#session.role==2">
																<button type="button"
																class="am-btn am-btn-default am-btn-xs am-text-secondary"
																onclick="toUpdate('<s:property value="id"/>')">
																<span class="am-icon-pencil-square-o"></span> 修改
																</button>
																
																
																<button type="button"
																	class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" type="button" onclick="toDelete('<s:property value="id"/>')">
																	<span class="am-icon-trash-o"></span> 删除
																</button>
															</s:if>
														</div>
													</div>
												</td>
											</tr>
											</s:iterator>
											<!--行end-->
										</tbody>
									</table>
									<div class="am-cf">
										<div class="am-fr">
											<ul class="am-pagination tpl-pagination">
												<li>
													<a href="javascript:doPage('${pageBean.prePage }')">上一页</a>
												</li>
												<li>
													<a href="javascript:doPage('${pageBean.nextPage }')">下一页</a>
												</li>
											</ul>
										</div>
									</div>
									<hr>
							</div>
						</div>
					</form>
					</div>
					<div class="tpl-alert"></div>
				</div>
			</div>
			<!--右边内容end-->
		</div>

		<!-- 删除对话框begin -->
		<div class="am-modal am-modal-confirm" tabindex="-1" id="delete_modal">
			<div class="am-modal-dialog">
				<div class="am-modal-hd">
					你，确定要删除这条记录吗？
				</div>
				<div class="am-modal-footer">
					<span class="am-modal-btn" data-am-modal-cancel>取消</span>
					<span class="am-modal-btn" data-am-modal-confirm>确定</span>
				</div>
			</div>
		</div>		
		<!-- 删除对话框end -->
		<div class="am-modal am-modal-no-btn" tabindex="-1" id="add-modal">
			<div class="am-modal-dialog">
				<div class="am-modal-hd">
					添加奖惩信息
					<a href="javascript: void(0)" class="am-close am-close-spin"
						data-am-modal-close>&times;</a>
				</div>
				<div class="am-modal-bd">
					<!-- 修改表单begin -->
					<form class="am-form" name="addForm" action="repe_add.action"
						method="post" onsubmit="return checkAdd()">
							<div class="am-g" style="margin-top: 4px;">
								<div class="am-u-sm-3 am-u-md-3 am-text-right">
									学生
								</div>
								<div class="am-u-sm-9 am-u-md-9 am-u-end col-end">
									<select id="sid" name="repe.student.id">
									</select>
								</div>
							</div>
							<div class="am-g" style="margin-top: 4px;">
								<div class="am-u-sm-3 am-u-md-3 am-text-right">
									内容
								</div>
								<div class="am-u-sm-9 am-u-md-9 am-u-end col-end">
									<textarea id="content" name="repe.content" rows="4"></textarea>
								</div>
							</div>
							<div class="am-g" style="margin-top: 4px;">
								<div class="am-u-sm-3 am-u-md-3  am-text-right">
									时间
								</div>
								<div class="am-u-sm-9 am-u-md-9 am-u-end col-end">
									<input type="text" id="rtime" name="repe.rtime" onclick="WdatePicker()">
								</div>
							</div>
	
							<div style="margin-top: 10px;">
							<button type="submit" class="am-btn am-btn-primary am-btn-xs">
								保存
							</button>
							<button type="reset" class="am-btn am-btn-primary am-btn-xs">
								取消
							</button>
						</div>	
					</form>
				</div>
			</div>
		</div>
		<!-- 详情对话框begin -->
		<div class="am-modal am-modal-no-btn" tabindex="-1" id="update-modal">
			<div class="am-modal-dialog">
				<div class="am-modal-hd">
					修改奖惩信息
					<a href="javascript: void(0)" class="am-close am-close-spin"
						data-am-modal-close>&times;</a>
				</div>
				<div class="am-modal-bd">
					<!-- 修改表单begin -->
					<form class="am-form" name="updateForm" action="repe_update.action"
						method="post" onsubmit="return checkUpdate()">
							<input type="hidden" id="id" name="id"/>
							<div class="am-g" style="margin-top: 4px;">
								<div class="am-u-sm-3 am-u-md-3 am-text-right">
									内容
								</div>
								<div class="am-u-sm-9 am-u-md-9 am-u-end col-end">
									<textarea id="content" name="repe.content" rows="4"></textarea>
								</div>
							</div>
							<div class="am-g" style="margin-top: 4px;">
								<div class="am-u-sm-3 am-u-md-3  am-text-right">
									时间
								</div>
								<div class="am-u-sm-9 am-u-md-9 am-u-end col-end">
									<input type="text" id="rtime" name="repe.rtime" onclick="WdatePicker()">
								</div>
							</div>
	
							<div style="margin-top: 10px;">
							<button type="submit" class="am-btn am-btn-primary am-btn-xs">
								保存
							</button>
							<button type="reset" class="am-btn am-btn-primary am-btn-xs">
								取消
							</button>
						</div>	
					</form>
				</div>
			</div>
		</div>
		<!-- 修改对话框end -->
		<script src="<%=Const.ROOT%>assets/js/jquery.min.js"></script>
		<script src="<%=Const.ROOT%>assets/js/amazeui.min.js"></script>
		<script src="<%=Const.ROOT%>assets/js/app.js"></script>
		<script src="<%=Const.ROOT%>js/ajaxfileupload.js"></script>
		<script src="<%=Const.ROOT%>My97DatePicker/WdatePicker.js"></script>
		<script>

		$(function(){
			  loadOptions("sid","-1");
		  });
		function loadOptions(domid,tid){
			$.getJSON("<%=Const.ROOT%>student_listJson.action",function(data){
					$("#"+domid).html("<option value='-1'>请选择学生</option>");
					$.each(data,function(index,item){
						if(item.id==tid){
							$("#"+domid).append("<option value='"+item.id+"' selected>"+(item.name)+"</option>");
						}else{
							$("#"+domid).append("<option value='"+item.id+"'>"+(item.name)+"</option>");
						}
					});
			});
		}
		function add() {
			$("#add-modal").modal({
				width: 700,
				height: 290
			});
		}
		function checkAdd(){
			if($("#add-modal #sid").val()=="-1"){
		  		alert("请选择学生");
		  		return false;
		  	}
			if($("#add-modal #content").val()==""){
		  		alert("请输入内容");
		  		return false;
		  	}
		  	if($("#add-modal #rtime").val()==""){
		  		alert("请输入时间");
		  		return false;
		  	}
		  	return true;
		}
		function checkUpdate(){
			if($("#update-modal #content").val()==""){
		  		alert("请输入内容");
		  		return false;
		  	}
		  	if($("#update-modal #rtime").val()==""){
		  		alert("请输入时间");
		  		return false;
		  	}
		  	return true;
		}
		
			function toDelete(id) {
				$("#delete_modal").modal({
					relatedTarget: this,
					onConfirm: function(options) {
						//执行
						location.href = "repe_delete.action?id=" + id;
					},
					onCancel: function() {
					}
				});
			}

		
			function toUpdate(id){
				$.getJSON("repe_detail.action",{"id":id},function(data){
					$("#update-modal #id").val(id);
					$("#update-modal #content").val(data.content);
					$("#update-modal #rtime").val(data.rtime);
					$("#update-modal").modal({width:700,height:250});
				})
			}

		
			function doPage(pageNo){
				$("#pageNo").val(pageNo);
				$("#sform").submit();
			}
			
</script>
	</body>

</html>